package com.xdf.zipperdye.controller;

import com.xdf.zipperdye.model.OrderDetail;
import com.xdf.zipperdye.service.OrderDetailService;
import com.xdf.zipperdye.utils.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "客户订单明细表")
@CrossOrigin
@RestController
@RequestMapping("/orderDetail")
public class OrderDetailController {
    @Autowired
    private OrderDetailService service;

    @ApiOperation(value="新增", notes="新增", produces="application/json")
    @PostMapping("/insert")
    public JsonResult insert(@RequestBody OrderDetail record){
        return JsonResult.ok(service.insertSelective(record));
    }

    @ApiOperation(value="删除", notes="删除", produces="application/json")
    @GetMapping("/delete/{id}")
    public JsonResult delete(@PathVariable Integer id){
        return JsonResult.ok(service.deleteByPrimaryKey(id));
    }

    @ApiOperation(value="修改", notes="修改", produces="application/json")
    @PostMapping("/update")
    public JsonResult update(@RequestBody OrderDetail record){
        return JsonResult.ok(service.updateByPrimaryKeySelective(record));
    }

    @ApiOperation(value="根据主键查询", notes="根据主键查询", produces="application/json")
    @GetMapping("/selectByPrimaryKey/{id}")
    public JsonResult selectByPrimaryKey(@PathVariable Integer id){
        return JsonResult.ok(service.selectByPrimaryKey(id));
    }

    @ApiOperation(value="根据外键查询", notes="根据外键查询，返回数组", produces="application/json")
    @GetMapping("/selectByPid/{pid}")
    public JsonResult selectByPid(@PathVariable Integer pid){
        return JsonResult.ok(service.selectByPid(pid));
    }

}
